{% extends 'base.html' %}

{% block content %}
  <h1>Responses</h1>
  <form method="GET">
    {{ filter.form }}
    <input class="btn btn-primary" type="submit" value="Find" />
  </form>
  {% for response in filter.qs %}
    <div class="card mb-3">
      {% if response.announcement.user == user %}
        <div class="card-body">
          <h5 class="card-title">Response on "{{ response.announcement.title }}"</h5>
          <p class="card-text">{{ response.text }}</p>
          <a href="{% url 'announcement_detail' response.announcement.pk %}" class="btn btn-primary">Go to announcement</a>

          <a href="{% url 'response_update' response.pk %}" class="btn btn-warning">Edit</a>
          <a href="{% url 'response_delete' response.pk %}" class="btn btn-danger">Delete</a>
          <div class="card-body">
            {% if not response.status %}
              <span class="text-danger">Not aproved!</span>
              <a href="{% url 'response_approve' response.id %}" class="btn btn-primary">Approve</a>
            {% else %}
              <span class="text-success">Approved!</span>
            {% endif %}
          </div>
        </div>
      {% endif %}
    </div>
  {% empty %}
    <p>No responses yet.</p>
  {% endfor %}
{% endblock %}
